from django.shortcuts import render
from django.http import Http404
from .models import Page


def page(request, slug):
    try:
        page = Page.objects.get(slug=slug, status=Page.STATUS.PUBLISHED)

        placeholders = {

        }

        # register placeholders.
        page.set_placeholders(placeholders)

        return render(request, 'page.html', {'page': page})
    except Page.DoesNotExist:
        # render 404 page
        raise Http404("Page Doesn't Not Exist!")
